import { Group, Sprite, SpriteMaterial } from 'three'

export const spriteGroup = new Group()
const num = 0
const width = 200
const height = 200
const speed = 1
for (let i = 0; i < num; i++) {
  const sprite = new Sprite(
    new SpriteMaterial({
      color: `rgb(255,255,255)`,
    })
  )
  let xQuadrant, zQuadrant
  const xRandom = Math.random() * 5
  const zRandom = Math.random() * 5
  if (xRandom > 0 && xRandom <= 2) {
    xQuadrant = 1
  } else {
    xQuadrant = -1
  }
  if (zRandom > 0 && zRandom <= 2) {
    zQuadrant = 1
  } else {
    zQuadrant = -1
  }

  //   sprite.scale.set(2, 2, 1)
  sprite.position.x = Math.random() * width * xQuadrant
  sprite.position.y = Math.random() * height
  sprite.position.z = Math.random() * width * zQuadrant
  spriteGroup.add(sprite)
}

export function spriteGroupAnimate() {
  spriteGroup.children.forEach((sprite) => {
    sprite.position.y -= speed
    if (sprite.position.y <= 0) {
      sprite.position.y = height
    }
  })
}

// console.log(spriteGroup)
